home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / hugegr.zip / HUGEGRID.DOC < prev    next >
Text File  |  1991-08-02  |  7KB  |  186 lines

  1.                                  HugeGrid 1.0
  2.                        Copyright 1991 Nelson Ford, PsL
  3.                     P.O.Box 35705  Houston, TX 77235-5705
  4.  
  5.  
  6.                                    LICENSE
  7.  
  8. 1. You may freely use and distributed this code in applications in which
  9.      this code makes up a small part of the program.
  10.  
  11. 2. You may freely distribute this code to other VB programmers, including
  12.      uploading it to BBS's or for a disk fee, as long as all related files
  13.      are distributed together and without any changes.
  14.  
  15. All I ask for the use of this code is that if you find a better way to do
  16. something than the methods I've used, I would appreciate your letting me know.
  17.  
  18.  
  19.  
  20.                                  REQUIREMENTS
  21.  
  22. Visual Basic is required, of course, and HUGEARR.DLL and GRID.VBX.
  23.  
  24. HUGEARR.DLL and GRID.VBX are not included with this set of files. They are
  25. available in separate archives on the MSLANG Forum's Data Libraries for
  26. downloading or you can get them on disk from PsL. (See the end of this file.)
  27.  
  28.  
  29.                                    PURPOSE
  30.  
  31. This is a sample application whose only purpose is to illustrate the coding
  32. needed to use a Huge Array in conjunction with a Grid Control. Even if you are
  33. using one but not the other, this sample code should come in handy. Getting
  34. everything to work right under all circumstances took about 30 hours or more
  35. of coding.
  36.  
  37.  
  38.                                  INTRODUCTION
  39.  
  40. The Huge Array DLL and the Grid Control VBX were produced by Microsoft and
  41. given to beta testers, but not included with Visual Basic when released.
  42.  
  43. It appears that they are bug-free, but probably were not included because they
  44. are not very robust. For example, getting Text out of a Grid cell by having to
  45. change the Grid.Row and Grid.Col is a very inefficient way to do things,
  46. neither is having to access a Huge Array like you would a data file.
  47.  
  48. Nevertheless, if you HAVE to have either an array larger than 64k (VB's usual
  49. limit) or a Grid control - you'll be glad that MS decided to release these to
  50. the public as freebies.
  51.  
  52.  
  53.                         HUGE ARRAY VS RANDOM DATA FILE
  54.  
  55. As you will see, sorting a 5000-element Huge Array takes a lot of time - two
  56. minutes on a 386-33. I haven't had a chance yet to compare the performance of
  57. a Huge Array versus a random access data file. (Scrolling seems to go at a
  58. respectable clip.)
  59.  
  60. It's possible that with a sufficiently large disk cache, a random access file
  61. would be as fast as the Huge Array and would have the advantage of being more
  62. secure as data is written to the disk when added or deleted. However, if your
  63. user is not using a large enough cache, then performance could be seriously
  64. degraded by using a random access disk file.
  65.  
  66. Because getting data to and from a Huge Array is more like accessing a Random
  67. access data file than using an actual in-memory data array, it should be
  68. possible to use most of these same routines with a data file if you do decide
  69. to go that way.
  70.  
  71.  
  72.                                 DOCUMENTATION
  73.  
  74. HUGEARR.DLL - This file goes into some directory in your PATH. This file and
  75. the next one are not included in this set. See REQUIREMENTS.
  76.  
  77. GRID.VBX - This file is loaded into your application via Alt-F-d "Add File".
  78.  
  79. HUGEGRID.BAS - The Declares in the Global file come with the HugeArr.DLL.
  80. Print the documentation that comes with HugeArr.DLL for reference in using it.
  81.  
  82.  
  83. HUGEGRID.FRM -
  84.  
  85. General
  86. DecrLastEl & IncrLastEl
  87.  
  88. When you delete an entry, several pointers have to be adjusted. This Sub
  89. makes sure that wherever you need to decrease LastElement, everything else
  90. gets done too.  IncrLastEl does the same for adding entries.
  91.  
  92. General
  93. Sub FillGrid(StartPt, StopPt, StartRow)
  94.  
  95. This routine gets data from the Array and puts it in the grid.
  96. StartPt and StopPt are the pointer numbers to start and stop with.
  97. StartRow says what row of the grid to start with.
  98.  
  99. General
  100. Function GetEl(x)
  101.  
  102. Gets the element of the Array that Pointer&(x) points to.
  103. You could format or otherwise manipulate the data at this point if needed.
  104.  
  105. General
  106. ScrollUp & ScrollDown
  107. Lets you scroll selected rows in the Grid up or down. Given the kludgy way
  108. that data has to moved from one Grid cell to another, it may be just as quick
  109. to use the FillGrid routine to read the data in from the HugeArray again, and
  110. it would save all this code.
  111.  
  112.  
  113. Form
  114. Load:
  115.  
  116. In setting up your grids, you may have to experiment (going back and forth
  117. between design and run-time) to find the desired column widths, since I
  118. haven't found any way to change them during design time.
  119.  
  120. Most of the VScroll values shown can be set at design time. They are included
  121. here to make them easier to see.
  122.  
  123. For ease of coming up with a lot of different text, numbers were used to fill
  124. the array. However, these ARE strings and when sorted, they are sorted as
  125. strings, not as numbers. (So you will see 1.1 10.1 100.1 ... 2.1 20.1, etc.)
  126.  
  127. If you enter a number in the Text box and select Insert, it will be entered
  128. alphabetically, not numerically. You could easily change the code to treat the
  129. data as numbers rather than text simply by using VAL() everywhere that data
  130. variables are used.
  131.  
  132. After loading up the array, the end of the array is displayed in the Grid. You
  133. could just as easily pick any other part of the array for the initial display,
  134. but don't forget to change Vscroll1.Value accordingly. (eg: If you display
  135. elements 1 - 10, set Vscroll1.Value to 10.)
  136.  
  137. Form
  138. B_Sort
  139. This is a QuickSort algorithm, which is one of the fastest general sorting
  140. algorithm available. Although numeric data is used for ease of filling up an
  141. array with different data, the numbers are store as strings and will be sorted
  142. in string order. (eg: 10 100 1000 before 20)
  143.  
  144. Form
  145. B_Del
  146. Deletes an array element. To save time, the element is not actually removed
  147. from the array. An array (Deleted&) is set up for keeping track of deleted
  148. entries and reusing that space on subsequent Adds.
  149.  
  150. Form
  151. B_Find
  152. Does a binary search.
  153.  
  154. Form
  155. B_Insert
  156. This is an alphabetic insert. It calls B_Find and then inserts the new data.
  157. This took a lot of time to work out the special cases, such as inserting a
  158. number at the beginning or end of the file.
  159.  
  160. Form
  161. B_Quit
  162. Be sure to quit the demo by clicking on Quit. This frees up memory for Windows
  163. that was used by the Huge Array.
  164.  
  165.  
  166.  
  167.  
  168.                             WHERE TO GET VB STUFF
  169.  
  170. This program was written by Nelson Ford, PsL.
  171.  
  172. You can find a lot of routines, sample programs, custom controls, and DLL's on
  173. Microsoft's MSLANG forum on CompuServe.
  174.  
  175. My company, Public (software) Library, also distributes a lot of VB goodies
  176. and programs. Call or write for a free copy of our monthly magazine and
  177. catalog:
  178.  
  179.                           Public (software) Library
  180.                                 P.O.Box 35705
  181.                             Houston, TX 77235-5705
  182.                              Orders: 800-242-4PsL
  183.                           Tech Support: 713-524-6394
  184.                               FAX: 713-524-6398
  185.                                 CIS: 71355,470
  186.